package com.erp.service;

import com.erp.bean.User;
import com.erp.dao.UserDao;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;

/**
 * @Author lqa
 * @Date 2022-04-20 15:59:16
 */
public class UserService {
    UserDao userDao = new UserDao();
    /* *
     * @author lqa
     * @name 登录
     * @time 15:59 2022/4/20
     * @param username: 账号
     * @param password: 密码
     **/
    public void login(String username, String password) throws Exception {
        // 实现登录逻辑
        if(StringUtils.isBlank(username) || StringUtils.isBlank(password)){
            throw new Exception("用户名或密码不能为空");
        }
        User user = userDao.getUserByUsername(username);
        if(user == null){
            throw new Exception("用户不存在");
        }
        System.out.println(user);
        if(!user.getPassword().equals(password)) {
            throw new Exception("密码错误");
        }
    }
}